#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
bool cmp(const string &a, const string &b)
{
	string s1 = a + b;
	string s2 = b + a;
	return s1 > s2;
}
int main()
{
	int n;
	while (cin >> n)
	{
		vector<string>v;
		for (int i = 0; i < n; i++)
		{
			string s;
			cin >> s;
			v.push_back(s);
		}
		sort(v.begin(), v.end(), cmp);
		string a = "";
		for (int i = 0; i < v.size(); i++)
		{
			a += v[i];
			cout << v[i];
		}
		cout << endl;
	}
	return 0;
}